<template>
  <!-- 辅导员管理页面 -->
  <div class="app-container">
    <el-row :gutter="20">
      <!--教师基本信息-->
      <el-col :span="24" :xs="24">
        <searchForm
          :formOptions="formOptions"
          @onSearch="onSearch"
          @onReset="onReset"
          :formLabelWidth="formLabelWidth"
          v-show="showSearch"
        >
        <el-form-item label="籍贯:">
            <!-- <el-cascader v-model="queryParams.deptId" :options="deptOptions" style="width: 200px"
              :props="{ value: 'id', currentLabels: 'label', checkStrictly: true }" @change="handleChange"></el-cascader> -->
              <el-cascader v-model="queryParams.bnpCode" :props="{ value: 'unitCode', currentLabels: 'label', checkStrictly: true }" clearable
              :options="options" @change="handlePlace"></el-cascader>
          </el-form-item>
        </searchForm>
        <el-row :gutter="10" class="mb8">

          <el-col :span="1.5">
            <el-button
              type="danger"
              plain
              icon="el-icon-delete"
              size="mini"
              :disabled="multiple"
              @click="handleDelete"
              v-hasPermi="['clr:counsellor:remove']"
              >删除</el-button
            >
            <el-button
              type="warning"
              plain
              icon="el-icon-download"
              size="mini"
              @click="handleExport"
               v-hasPermi="['clr:counsellor:export']"
              >导出</el-button
            >
          </el-col>
          <right-toolbar
            :showSearch.sync="showSearch"
            @queryTable="getList"
          ></right-toolbar>
        </el-row>

        <el-table :data="roleList" @selection-change="handleSelectionChange">
          <el-table-column type="selection" width="55" align="center" />
          <el-table-column
            label="教工号"
            prop="teacher.tno"
            align="center"
            show-overflow-tooltip
          />
          <el-table-column
            label="姓名"
            prop="teacher.name"
            show-overflow-tooltip
            align="center"
          />
          <el-table-column
            label="性别"
            prop="teacher.sex"
            show-overflow-tooltip
            align="center"
          >
            <template slot-scope="scope">
              <dict-tag
                :options="dict.type.sys_user_sex"
                :value="scope.row.teacher.sex"
              />
            </template>
          </el-table-column>
          <el-table-column
            label="任职院系"
            prop="teacher.deptNames"
            align="center"
            show-overflow-tooltip
          />
          <el-table-column
            label="籍贯"
            prop="teacher.birthplaceName"
            align="center"
            show-overflow-tooltip
          />
          <el-table-column
            label="所带班级数"
            prop="classTotal"
            align="center"
            sortable
            :show-overflow-tooltip="true"
          />
          <el-table-column
            label="所带学生总人数"
            prop="total"
            sortable
            align="center"
            show-overflow-tooltip
          />
          <el-table-column
            label="联系电话"
            prop="teacher.phone"
            align="center"
          />
          <el-table-column
            label="操作"
            align="center"
            width="250"
            class-name="small-padding fixed-width"
          >
            <template slot-scope="scope">
              <el-button size="mini" type="text" @click="details(scope.row)"
                >查看详情</el-button
              >
              <!-- <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:role:edit']"
          >修改</el-button> -->
              <el-button
                size="mini"
                type="text"
                icon="el-icon-delete"
                @click="handleDelete(scope.row)"
                v-hasPermi="['clr:counsellor:remove']"
                >删除</el-button
              >
              <el-button
                size="mini"
                type="text" 
                @click="handDistribution(scope.row)"
                v-hasPermi="['clr:counsellor:class:add']"
                >分配班级</el-button
              >
              <el-button
                size="mini"
                type="text" 
                @click="handAdjust(scope.row)"
                v-hasPermi="['clr:counsellor:teacher:edit']"
                >院系调整</el-button
              >
            </template>
          </el-table-column>
        </el-table>

        <pagination
          v-show="total > 0"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />
      </el-col>
    </el-row>
    <el-dialog
      :title="title"
      :visible.sync="open"
      width="60%"
      ppend-to-body
      @close="CloseIn"
      destroy-on-close
    >
      <el-form ref="form" :model="form" :rules="rules" label-width="95px">
        <el-row>
          <el-col :span="8">
            <el-form-item label="所属院系" prop="deptId">
              <el-cascader
                v-model="form.deptId"
                :options="deptOptions"
                :props="{ value: 'id',currentLabels: 'label',checkStrictly: true }"
                style="width: 100%"
                @change="handleChange"
                clearable
                disabled
              ></el-cascader>
              <!-- <el-select
                v-model="form.deptId"
                placeholder="请选择"
                disabled
                clearable
                class="elSelect"
                @change="handleChange"
                style="width: 100%"
              >
                <el-option
                  v-for="item in deptOptions"
                  :key="item.deptId"
                  :label="item.deptName"
                  :value="item.deptId"
                ></el-option>
              </el-select> -->
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="入职时间" prop="admissionTime">
              <el-date-picker
                v-model="form.admissionTime"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择入职时间"
                style="width: 100%"
                disabled
              ></el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="工号" prop="tno">
              <el-input
                v-model.trim="form.tno"
                clearable
                disabled
                placeholder="请输入工号"
                maxlength="30"
              />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="姓名" prop="name">
              <el-input
                v-model.trim="form.name"
                clearable
                disabled
                placeholder="请输入姓名"
                maxlength="10"
              />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="性别" prop="sex">
              <el-select
                v-model="form.sex"
                clearable
                disabled
                placeholder="请选择性别"
                style="width: 100%"
              >
                <el-option
                  v-for="dict in dict.type.sys_user_sex"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="在职状态" prop="postStatus">
              <el-select
                v-model="form.postStatus"
                clearable
                placeholder="请选择在职状态"
                style="width: 100%"
                disabled
              >
                <el-option
                  v-for="dict in dict.type.basic_post_status"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="血型" prop="bloodType">
              <el-select
                clearable
                v-model="form.bloodType"
                disabled
                placeholder="请选择血型"
                style="width: 100%"
              >
                <el-option
                  v-for="dict in dict.type.basic_blood_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="身份证件号" prop="cardCode">
              <el-input
                v-model.trim="form.cardCode"
                placeholder="请输入身份证件号"
                clearable
                disabled
                maxlength="18"
              />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="出生日期" prop="birthday">
              <el-date-picker
                v-model="form.birthday"
                disabled
                type="date"
                placeholder="选择出生日期"
                style="width: 100%"
                value-format="yyyy-MM-dd"
                format="yyyy-MM-dd"
              ></el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="联系方式" prop="phone">
              <el-input
                v-model.trim="form.phone"
                disabled
                placeholder="请输入联系方式"
                maxlength="11"
              />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="民族" prop="nation">
              <el-select
                v-model="form.nation"
                disabled
                placeholder="请选择民族"
                style="width: 100%"
              >
                <el-option
                  v-for="dict in dict.type.bc_nation_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="政治面貌" prop="political">
              <el-select
                v-model="form.political"
                disabled
                placeholder="请选择政治面貌"
                style="width: 100%"
              >
                <el-option
                  v-for="dict in dict.type.bc_political_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="曾用名" prop="formerName">
              <el-input
                v-model.trim="form.formerName"
                disabled
                placeholder="请输入曾用名"
                maxlength="10"
              />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="籍贯" prop="birthplace">
              <el-cascader
                v-model="form.birthplace"
                clearable
                style="width: 100%"
                disabled
                :props="{ value: 'unitCode', currentLabels: 'label',checkStrictly: true  }"
                :options="options"
              ></el-cascader>
              <!-- <el-input v-model.trim="form.bnpId" disabled placeholder="请输入籍贯" maxlength="30" /> -->
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="学历" prop="education">
              <el-select
                v-model="form.education"
                disabled
                placeholder="请选择学历"
                style="width: 100%"
              >
                <el-option
                  v-for="dict in dict.type.basic_education_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="学位" prop="acDegree">
              <el-select
                v-model="form.acDegree"
                disabled
                placeholder="请选择学位"
                style="width: 100%"
              >
                <el-option
                  v-for="dict in dict.type.basic_degree_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item label="职称" prop="title">
              <el-select
                v-model="form.title"
                disabled
                placeholder="请选择职称"
                style="width: 100%"
              >
                <el-option
                  v-for="dict in dict.type.basic_title_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="职称级别" prop="titleLevel">
              <el-select
                v-model="form.titleLevel"
                disabled
                placeholder="请选择职称级别"
                style="width: 100%"
              >
                <el-option
                  v-for="dict in dict.type.basic_title_level"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <!-- 班级选择：<el-badge :value="sendUserIds.length" :hidden="!sendUserIds.length" :type="'primary'">
                <el-button size="small" @click="selectUserBtn">选择</el-button>
      </el-badge>-->

      <div style="display: flex; justify-content: space-between;margin-top: 10PX;">
        <h2>工作经历</h2>
        <div>
          <el-button type="warning" size="mini" @click="experience"  v-hasPermi="['clr:counsellor:clrWorkExport']">导出工作经历</el-button>
        </div>   
      </div>
      <el-table
        :data="clrWorkHistoryList"
        @selection-change="handleClrWorkHistorySelectionChange"
        ref="clrWorkHistory"
      >
        <el-table-column label="序号" align="center" type="index" width="50" />
        <el-table-column
          label="公司名称"
          prop="cName"
          align="center"
        ></el-table-column>
        <el-table-column
          label="开始时间"
          prop="startDate"
          align="center"
        ></el-table-column>
        <el-table-column
          label="结束时间"
          prop="endDate"
          align="center"
        ></el-table-column>
        <el-table-column
          label="职位名称"
          prop="jobTitle"
          align="center"
        ></el-table-column>
        <el-table-column
          label="操作"
          align="center"
          class-name="small-padding fixed-width"
        >
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              icon="el-icon-view"
              @click="workDetails(scope.row)"
              >查看详情</el-button
            >
          </template>
        </el-table-column>
      </el-table>
    </el-dialog>  
     
       

    <!-- 查看审批详情 -->
    <el-dialog
      :title="title"
      :visible.sync="open"
      width="60%"
      ppend-to-body
      @close="CloseIn"
      destroy-on-close
    >
      <el-form ref="form" :model="form" :rules="rules" label-width="95px">
        <el-row>
          <el-col :span="8">
            <el-form-item label="所属院系" prop="deptId">
              <el-cascader
                v-model="form.deptId"
                :options="deptOptions"
                :props="{ value: 'id',currentLabels: 'label',checkStrictly: true }"
                style="width: 100%"
                @change="handleChange"
                clearable
                disabled
              ></el-cascader>
              <!-- <el-select
                v-model="form.deptId"
                placeholder="请选择"
                disabled
                clearable
                class="elSelect"
                @change="handleChange"
                style="width: 100%"
              >
                <el-option
                  v-for="item in deptOptions"
                  :key="item.deptId"
                  :label="item.deptName"
                  :value="item.deptId"
                ></el-option>
              </el-select> -->
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="入职时间" prop="admissionTime">
              <el-date-picker
                v-model="form.admissionTime"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择入职时间"
                style="width: 100%"
                disabled
              ></el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="工号" prop="tno">
              <el-input
                v-model.trim="form.tno"
                clearable
                disabled
                placeholder="请输入工号"
                maxlength="30"
              />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="姓名" prop="name">
              <el-input
                v-model.trim="form.name"
                clearable
                disabled
                placeholder="请输入姓名"
                maxlength="10"
              />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="性别" prop="sex">
              <el-select
                v-model="form.sex"
                clearable
                disabled
                placeholder="请选择性别"
                style="width: 100%"
              >
                <el-option
                  v-for="dict in dict.type.sys_user_sex"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="在职状态" prop="postStatus">
              <el-select
                v-model="form.postStatus"
                clearable
                placeholder="请选择在职状态"
                style="width: 100%"
                disabled
              >
                <el-option
                  v-for="dict in dict.type.basic_post_status"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="血型" prop="bloodType">
              <el-select
                clearable
                v-model="form.bloodType"
                disabled
                placeholder="请选择血型"
                style="width: 100%"
              >
                <el-option
                  v-for="dict in dict.type.basic_blood_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="身份证件号" prop="cardCode">
              <el-input
                v-model.trim="form.cardCode"
                placeholder="请输入身份证件号"
                clearable
                disabled
                maxlength="18"
              />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="出生日期" prop="birthday">
              <el-date-picker
                v-model="form.birthday"
                disabled
                type="date"
                placeholder="选择出生日期"
                style="width: 100%"
                value-format="yyyy-MM-dd"
                format="yyyy-MM-dd"
              ></el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="联系方式" prop="phone">
              <el-input
                v-model.trim="form.phone"
                disabled
                placeholder="请输入联系方式"
                maxlength="11"
              />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="民族" prop="nation">
              <el-select
                v-model="form.nation"
                disabled
                placeholder="请选择民族"
                style="width: 100%"
              >
                <el-option
                  v-for="dict in dict.type.bc_nation_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="政治面貌" prop="political">
              <el-select
                v-model="form.political"
                disabled
                placeholder="请选择政治面貌"
                style="width: 100%"
              >
                <el-option
                  v-for="dict in dict.type.bc_political_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="曾用名" prop="formerName">
              <el-input
                v-model.trim="form.formerName"
                disabled
                placeholder="请输入曾用名"
                maxlength="10"
              />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="籍贯" prop="bnpId">
              <el-cascader
                v-model="form.bnpId"
                clearable
                style="width: 100%"
                disabled
                :props="{ value: 'unitCode', currentLabels: 'label' }"
                :options="options"
              ></el-cascader>
              <!-- <el-input v-model.trim="form.bnpId" disabled placeholder="请输入籍贯" maxlength="30" /> -->
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="学历" prop="education">
              <el-select
                v-model="form.education"
                disabled
                placeholder="请选择学历"
                style="width: 100%"
              >
                <el-option
                  v-for="dict in dict.type.basic_education_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="学位" prop="acDegree">
              <el-select
                v-model="form.acDegree"
                disabled
                placeholder="请选择学位"
                style="width: 100%"
              >
                <el-option
                  v-for="dict in dict.type.basic_degree_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item label="职称" prop="title">
              <el-select
                v-model="form.title"
                disabled
                placeholder="请选择职称"
                style="width: 100%"
              >
                <el-option
                  v-for="dict in dict.type.basic_title_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="职称级别" prop="titleLevel">
              <el-select
                v-model="form.titleLevel"
                disabled
                placeholder="请选择职称级别"
                style="width: 100%"
              >
                <el-option
                  v-for="dict in dict.type.basic_title_level"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <!-- 班级选择：<el-badge :value="sendUserIds.length" :hidden="!sendUserIds.length" :type="'primary'">
                <el-button size="small" @click="selectUserBtn">选择</el-button>
      </el-badge>-->

      <div style="display: flex; justify-content: space-between;margin-top: 10PX;">
        <h2>工作经历</h2>
        <div>
          <el-button type="warning" size="mini" @click="experience"  v-hasPermi="['clr:counsellor:clrWorkExport']">导出工作经历</el-button>
        </div>   
      </div>
      <el-table
        :data="clrWorkHistoryList"
        @selection-change="handleClrWorkHistorySelectionChange"
        ref="clrWorkHistory"
      >
        <el-table-column label="序号" align="center" type="index" width="50" />
        <el-table-column
          label="公司名称"
          prop="cName"
          align="center"
        ></el-table-column>
        <el-table-column
          label="开始时间"
          prop="startDate"
          align="center"
        ></el-table-column>
        <el-table-column
          label="结束时间"
          prop="endDate"
          align="center"
        ></el-table-column>
        <el-table-column
          label="职位名称"
          prop="jobTitle"
          align="center"
        ></el-table-column>
        <el-table-column
          label="操作"
          align="center"
          class-name="small-padding fixed-width"
        >
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              icon="el-icon-view"
              @click="workDetails(scope.row)"
              >查看详情</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <el-dialog
        width="50%"
        title="工作经历"
        :visible.sync="innerVisible"
        append-to-body
        destroy-on-close
      >
        <el-form
          ref="formWork"
          :model="formWork"
          :rules="workRules"
          label-width="90px"
        >
          <el-row>
            <el-col :span="12">
              <el-form-item label="公司名称" prop="cName">
                <el-input
                  v-model="formWork.cName"
                  disabled
                  placeholder="请输入公司名称"
                  maxlength="30"
                />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="职位名称" prop="jobTitle">
                <el-input
                  v-model="formWork.jobTitle"
                  disabled
                  placeholder="请输入职位名称"
                  maxlength="30"
                />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="起止时间">
                <el-date-picker
                  v-model="dataTime"
                  type="daterange"
                  range-separator="至"
                  start-placeholder="开始日期"
                  end-placeholder="结束日期"
                  value-format="yyyy-MM-dd"
                  disabled
                ></el-date-picker>
              </el-form-item>
            </el-col>

            <el-col :span="24">
              <el-form-item label="工作内容" prop="workContent">
                <editor v-model="formWork.workContent" :min-height="180" />
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="工作业绩" prop="workPerformance">
                <editor v-model="formWork.workPerformance" :min-height="180" />
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="primary" @click="submitWork" :disabled="workDisabled"
            >确 定</el-button
          >
          <el-button @click="innerVisible = false">取 消</el-button>
        </div>
      </el-dialog>
      <h2>背景</h2>
      <!-- <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="educationalVisible = true">新增</el-button> -->
      <el-table :data="clrEducationList">
        <el-table-column
          label="学历"
          prop="education"
          align="center"
          show-overflow-tooltip
        >
          <template slot-scope="scope">
            <dict-tag
              :options="dict.type.basic_education_type"
              :value="scope.row.education"
            />
          </template>
        </el-table-column>
        <el-table-column
          label="毕业学校"
          prop="sName"
          show-overflow-tooltip
          align="center"
        />
        <el-table-column
          label="毕业专业"
          prop="gMajor"
          show-overflow-tooltip
          align="center"
        />
        <el-table-column
          label="学习方式"
          prop="lStyle"
          show-overflow-tooltip
          align="center"
        >
          <template slot-scope="scope">
            <dict-tag
              :options="dict.type.clr_learning_style"
              :value="scope.row.lStyle"
            />
          </template>
        </el-table-column>
        <el-table-column
          label="学制"
          prop="eSystem"
          show-overflow-tooltip
          align="center"
        >
          <template slot-scope="scope">
            <dict-tag
              :options="dict.type.bc_speciality_type"
              :value="scope.row.eSystem"
            />
          </template>
        </el-table-column>
        <el-table-column
          label="毕业时间"
          prop="endDate"
          align="center"
          show-overflow-tooltip
        />
        <el-table-column
          label="操作"
          align="center"
          class-name="small-padding fixed-width"
        >
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              icon="el-icon-view"
              @click="educationDetails(scope.row)"
              >查看详情</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <h2>所带班级</h2> 
      <el-button
              type="danger"
              plain
              icon="el-icon-delete"
              size="mini"
              @click="handleRemove" :disabled="multipleClass"
              v-hasPermi="['clr:counsellor:class:remove']" style="margin-bottom: 5px;"
              >删除所带班级</el-button
            >
      <el-table :data="classList" ref="clrWorkHistory"  @selection-change="handleDelChange">
        <el-table-column type="selection" width="55" align="center" />
        <el-table-column label="序号" align="center" type="index" width="50" />
        <el-table-column
          label="所属院系"
          prop="deptNames"
          show-overflow-tooltip
          align="center"
        ></el-table-column>
        <el-table-column
          label="专业"
          prop="specialtyName"
          align="center"
        ></el-table-column>
        <el-table-column
          label="入学年级"
          prop="gradeName"
          align="center"
        ></el-table-column>
        <el-table-column
          label="班号"
          prop="classCode"
          align="center"
        ></el-table-column>
        <el-table-column
          label="班级名称"
          prop="className"
          show-overflow-tooltip 
          align="center"
        ></el-table-column>
        <el-table-column
          label="班级人数"
          prop="classSize"
          align="center"
        ></el-table-column>
      </el-table>
      <el-dialog
        width="50%"
        title="教育背景"
        :visible.sync="educationalVisible"
        append-to-body
        destroy-on-close
      >
        <el-form
          ref="educationFrom"
          :model="educationFrom"
          :rules="educationRole"
          label-width="110px"
        >
          <el-row>
            <el-col :span="12">
              <el-form-item label="学历" prop="education">
                <el-select
                  v-model="educationFrom.education"
                  disabled
                  placeholder="请选择"
                  style="width: 100%"
                >
                  <el-option
                    v-for="dict in dict.type.basic_education_type"
                    :key="dict.index"
                    :label="dict.label"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="毕业学校" prop="sName">
                <el-input
                  v-model="educationFrom.sName"
                  disabled
                  placeholder="请输入毕业学校"
                  maxlength="30"
                />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="学校类型" prop="sType">
                <el-select
                  v-model="educationFrom.sType"
                  disabled
                  placeholder="请选择"
                  style="width: 100%"
                >
                  <el-option
                    v-for="dict in dict.type.clr_school_type"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="授予国家或地区" prop="educationCountry">
                <el-select
                  v-model="educationFrom.educationCountry"
                  placeholder="请选择"
                  style="width: 100%"
                  disabled
                >
                  <el-option
                    v-for="dict in dict.type.clr_country_type"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="入校时间" prop="startDate">
                <el-date-picker
                  v-model="educationFrom.startDate"
                  type="date"
                  value-format="yyyy-MM-dd"
                  disabled
                ></el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="毕业时间" prop="endDate">
                <el-date-picker
                  v-model="educationFrom.endDate"
                  type="date"
                  value-format="yyyy-MM-dd"
                  disabled
                ></el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="学科" prop="discipline">
                <el-input
                  v-model="educationFrom.discipline"
                  disabled
                  placeholder="请输入学科"
                  maxlength="30"
                />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="毕业专业" prop="gMajor">
                <el-input
                  v-model="educationFrom.gMajor"
                  disabled
                  placeholder="请输入毕业专业"
                  maxlength="30"
                />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="学习形式" prop="lModality">
                <el-select
                  v-model="educationFrom.lModality"
                  disabled
                  placeholder="请选择"
                  style="width: 100%"
                >
                  <el-option
                    v-for="dict in dict.type.clr_learning_forms"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="学习方式" prop="lStyle">
                <el-select
                  v-model="educationFrom.lStyle"
                  disabled
                  placeholder="请选择"
                  style="width: 100%"
                >
                  <el-option
                    v-for="dict in dict.type.clr_learning_style"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="学制" prop="eSystem">
                <el-select
                  v-model="educationFrom.eSystem"
                  disabled
                  placeholder="请选择"
                  style="width: 100%"
                >
                  <el-option
                    v-for="dict in dict.type.bc_speciality_type"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="是否最高学历" prop="isEducation">
                <el-select
                  v-model="educationFrom.isEducation"
                  placeholder="请选择"
                  style="width: 100%"
                  disabled
                >
                  <el-option
                    v-for="dict in dict.type.sys_yes_no"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="学位" prop="aDegree">
                <el-input
                  v-model="educationFrom.aDegree"
                  disabled
                  placeholder="请输入学习形式"
                  maxlength="30"
                />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="学位类型" prop="degreeType">
                <el-select
                  v-model="educationFrom.degreeType"
                  disabled
                  placeholder="请选择"
                  style="width: 100%"
                >
                  <el-option
                    v-for="dict in dict.type.basic_degree_type"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="学位授予国家" prop="degreeCountry">
                <el-select
                  v-model="educationFrom.degreeCountry"
                  placeholder="请选择"
                  style="width: 100%"
                  disabled
                >
                  <el-option
                    v-for="dict in dict.type.clr_country_type"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="学位授予单位" prop="degreeUnit">
                <el-input
                  v-model="educationFrom.degreeUnit"
                  placeholder="请输入学位授予单位"
                  maxlength="30"
                  disabled
                />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="学位授予日期" prop="degreeDate">
                <el-date-picker
                  v-model="educationFrom.degreeDate"
                  type="date"
                  value-format="yyyy-MM-dd"
                  disabled
                ></el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="是否最高学位" prop="isDegree">
                <el-select
                  v-model="educationFrom.isDegree"
                  placeholder="请选择"
                  disabled
                  style="width: 100%"
                >
                  <el-option
                    v-for="dict in dict.type.sys_yes_no"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="学位专业" prop="degreeMajor">
                <el-input
                  v-model="educationFrom.degreeMajor"
                  disabled
                  placeholder="请输入学位专业"
                  maxlength="30"
                />
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>

        <div slot="footer" class="dialog-footer">
          <el-button
            type="primary"
            @click="submitEducation"
            :disabled="educationDisabled"
            >确 定</el-button
          >
          <el-button @click="educationalCancel">取 消</el-button>
        </div>
      </el-dialog>
      <!-- <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">通 过</el-button>
        <el-button @click="refuse">拒 绝</el-button>
      </div> -->
    </el-dialog>
    <fromIndex ref="editDlgRef" @getDate="allot"></fromIndex>
    <adjust ref="adjustDlgRef" @getAdjust="adjustment"></adjust>
  </div>
</template>

<script>
import {
  counsellorList,
  unabsorbedList,
  counsellor,
  delCounsellor,
  counsellorInfor,
  updataCounsellor,
  classAdd,
  teacherAdjust,
  classRemove,counsellorInforTid
} from "@/api/counselor/index";
import { counsellorCid } from "@/api/counselor/index";
import { deptTreeSelectAll } from "@/api/system/user";
import { getProvinceTree } from "@/api/information/classInfor";
import searchForm from "@/components/Search/searchForm.vue";
import fromIndex from './component/formIndex.vue'
import adjust from './component/adjust.vue'
import { getDicts } from "@/api/system/dict/type";




export default {
  name: "Role",
  dicts: [
    "basic_education_type", // 学历类型
    "basic_degree_type", // 学位类型
    "sys_user_sex", // 性别    
    "basic_title_type", // 职称
    "basic_title_level", // 职称级别
    "basic_blood_type", // 血型
    "bc_political_type", // 政治面貌
    "bc_nation_type", // 民族类型
    "clr_counsellor_type", // 是否辅导员
    "clr_cthr_type", // 是否班主任
    "bc_office_type", // 任职类型
    "basic_post_status", //在岗状态
    "clr_learning_style", //学习方式
    "clr_learning_forms", //学习形式
    "clr_school_type", //学校类型
    "sys_yes_no", //学位类型
    "bc_speciality_type", //学制类型
    'clr_country_type'
  ], 
  components: {
    searchForm,
    fromIndex,
    adjust
    // treeIndex
  },

  data() {
    return {
      formLabelWidth: "85px",
      formOptions: [
        {
          label: "院系",
          prop: "deptId",
          element: "el-cascader",
          options: [],
          placeholder: "请选择院系",
        },
        {
          label: "教工号",
          prop: "tno",
          element: "el-input",
          placeholder: "请输入教工号",
        },
        {
          label: "姓名",
          prop: "teacherName",
          element: "el-input",
          placeholder: "请输入姓名",
        },
        {
          label: "性别",
          prop: "sex",
          element: "el-select",
          options: [],
          placeholder: "请选择性别",
        },
        
        {
          label: "联系电话",
          prop: "phone",
          element: "el-input",
          placeholder: "请输入联系电话",
        },
      ],
      educationFrom: {
        sName: "",
      }, // 教育背景参数
      clrEducationList: [], //
      formWork: {},
      clrWorkHistoryList: [],
      clrApprRecordList: [],
      classList: [],
      educationSname: [],
      dataTime: [],
      options: [],
      workDisabled: false,
      educationDisabled: false,
      distributionOpen: false, // 分配班级弹窗
   
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      names: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      multipleClass: true,
      multipleEducation: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 角色表格数据
      roleList: [],
      dataList: [], // 获取教师信息列表数据
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 是否显示弹出层（数据权限）
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        roleName: undefined,
        roleKey: undefined,
        status: undefined,
      },
      deptOptions: [],
      // 表单参数
      form: {
        tno: "",
      },
      formTeacher: {
        isClassThr: "",
        isClr: "",
      },
      defaultProps: {
        children: "children",
        label: "label",
      },
      workCname: [],
      innerVisible: false, // 添加工作经历弹窗
      educationalVisible: false, // 教育背景弹窗
      // 表单校验
      rules: {
        isClr: [
          { required: true, message: "请选择是否辅导员", trigger: "change" },
        ],
        isClassThr: [
          { required: true, message: "请选择是否班主任", trigger: "change" },
        ],
      },
      workRules: {
        cName: [{ required: true, message: "请输入公司名称", trigger: "bulr" }],
        jobTitle: [
          { required: true, message: "请输入职务名称", trigger: "bulr" },
        ],
        startDate: [
          { required: true, message: "请选择时间", trigger: "change" },
        ],
        endDate: [{ required: true, message: "请选择时间", trigger: "change" }],
      },
      educationRole: {
        education: [
          { required: true, message: "请选择学历", trigger: "change" },
        ],
        sName: [{ required: true, message: "请输入毕业学校", trigger: "bulr" }],
        gMajor: [
          { required: true, message: "请输入毕业专业", trigger: "bulr" },
        ],
        startDate: [
          { required: true, message: "请选择入校时间", trigger: "change" },
        ],
        endDate: [
          { required: true, message: "请选择毕业时间", trigger: "change" },
        ],
        lStyle: [
          { required: true, message: "请选择学习方式", trigger: "change" },
        ],
        eSystem: [{ required: true, message: "请选择学制", trigger: "change" }],
      },
      restaurants: [],
      teacherListAll: [],
      menus: [],
      subMenuList: [],
      openKeys: [],
      selectedKeys: [],
      markDownTxt: "",
      searchcursom: "",
      helpList: [],
      classIds: [],
      tId: '',
      cId:''
     
    };
  },
  async created() {
    this.getList();
    this.department();
    getDicts("sys_user_sex").then((res) => {
      this.formOptions[3].options = res.data.map((item) => {
        return {
          value: item["dictValue"],
          label: item["dictLabel"],
        };
      });
    });
    // 籍贯下拉书
    getProvinceTree().then((response) => {
      this.options = response.data;
      this.formOptions[4].options = response.data;
    });
  },
  mounted() {
    // console.log(this.restaurants, "this");
  },
  methods: {
  handleRemove(){
    classRemove(this.cId,{classIds:this.classIds.join(',')}).then(res =>{
       if(res.code == 200){
        this.$modal.msgSuccess("删除成功");
        counsellorInforTid(this.tId).then(require => {
          console.log(require,'删除成功')
          this.classList = require.data.classList;
        })
       }
      })
  },
    // 分配班级操作
    handDistribution(row) {
      this.$refs.editDlgRef.openIndex(row)
    },
    // 分配班级操作
    handAdjust(row) {
      this.$refs.adjustDlgRef.openIndex(row)
    },
    // 确认分配
    allot(data) {
     
     data.classList.forEach(e => {
      if(e.id){
        e.classId = e.id
      }
     })
     console.log(data,'tijioap')
      classAdd(data).then(res =>{
        console.log(res,'chengg')
        if(res.code == 200) {
          this.$modal.msgSuccess('调整班级成功')
          this.getList()
        }
       
      })
    },
    // 院系调整
    adjustment(data) {
   
     console.log(data,'tijioap')
     teacherAdjust(data).then(res =>{
        console.log(res,'院系调整')
        if(res.code == 200) {
          this.$modal.msgSuccess('院系调整成功')
          this.getList()
        }
       
      })
    },
    handleSelect(item) {
      console.log(item);
      this.formTeacher.tId = "";
      // this.formTeacher.cId = ''
      unabsorbedList({ tno: item.address, name: item.value }).then((res) => {
        console.log(res, "教师信息列表");
        this.dataList = res.rows;
      });
    },
    querySearch(queryString, cb) {
      if (queryString == "") return; //如果输入框无内容，不调接口
      unabsorbedList({ name: queryString }).then((res) => {
        console.log(res, "ddd");
        if (res && res.code == 200) {
          //传关键字后返回的结果就是筛选后的
          this.helpList = res.rows.map((item) => {
            return {
              value: item["name"],
              address: item["tno"],
            };
          });
          var helpList = this.helpList;
          var results = queryString
            ? helpList.filter(this.createFilter(queryString))
            : helpList;
          // 调用 callback 返回建议列表的数据
          cb(results);
        }
      });
    },
    handleChange(value) {
      if (value) {
        this.form.deptId = value[value.length - 1];
      }
      // this.form.deptId = value[2];
      // this.form.multistage = value + "";
    },
    details(row) {
      this.open = true;
      this.department();
      this.title = "查看辅导员详细信息";
      counsellorCid(row.cId).then((res) => {
        console.log(res);
        this.cId = res.data.cId;
        this.tId = res.data.tId;
        this.clrEducationList = res.data.clrEducationList;
        this.clrWorkHistoryList = res.data.clrWorkHistoryList;
        this.classList = res.data.classList;
        this.form = res.data.teacher;
      });
    },
    createFilter(queryString) {
      return (item) => {
        return (
          item.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0
        );
      }; //fVcHelpCenterName是接口返回的名称和输入的名称做对比
    },
    //下拉点击之后，把id传给menu的selectedKeys 数组，实现定位高亮效果，调用菜单的点击事件，实现显示对应内容
    handleSelects(item) {
      this.handleSelect(item);
    },
    // 籍贯选择赋值
    handlePlace(data) {
      // this.queryParams.nativePlace = data[data.length - 1]
      this.queryParams.bnpCode = data[data.length - 1]
    },
    // 添加工作经历
    handleAddClrWorkHistory() {
      this.innerVisible = true;
      this.workDisabled = false;
      this.formWork = {};
    },
    // tree树形选中的值
    handleNodeClick(data) {
      // console.log(data.label, "选中的值");
      this.queryParams.deptId = data.id;
      this.getList();
    },
    // 获取部门信息
    async department() {
      // await deptTreeSelect().then(res => {
      //   this.deptOptions = res.data;
      // });
      deptTreeSelectAll().then((res) => {
        this.deptOptions = res.data;
        this.formOptions[0].options = res.data
        // this.formOptions[0].options = res.data.map((item) => {
        //   return {
        //     value: item.id,
        //     label: item.label,
        //   };
        // });
      });
    },
    // 添加教育背景
    educationalAdd() {
      this.educationalVisible = true;
      this.educationDisabled = false;
      this.educationFrom = {};
    },
    // 起止时间
    dateTimes() {
      console.log(this.dataTime, "dateTime");
      this.formWork.startDate = this.dataTime[0];
      this.formWork.endDate = this.dataTime[1];
    },
    setText(html) {
      return html.replace(/<(p|div)[^>]*>(<br\/?>|&nbsp;)<\/\1>/gi, '\n')
        .replace(/<br\/?>/gi, '\n')
        .replace(/<[^>/]+>/g, '')
        .replace(/(\n)?<\/([^>]+)>/g, '')
        .replace(/\u00a0/g, ' ')
        .replace(/&nbsp;/g, ' ')
        .replace(/<img[^>]+src\\s*=\\s*['\"]([^'\"]+)['\"][^>]*>/g, '')
        .replace(/<\/?(img|table)[^>]*>/g, "")   // 去除图片和表格
        .replace(/<\/?(a)[^>]*>/g, "")			//  去除a标签
    },
    // 工作经历
    submitWork() {
      this.formWork.workPerformance = this.setText(this.formWork.workPerformance)
      this.formWork.workContent = this.setText(this.formWork.workContent)
      console.log(this.dataTime, "submitWork");
      if (this.dataTime.length == 0) {
        this.$modal.msgWarning("请选择时间");
      } else {
        if (this.clrWorkHistoryList.length > 0) {
          this.clrWorkHistoryList.forEach((element) => {
            if (element.cName == this.formWork.cName) {
              this.$modal.msgWarning("添加的工作单位已存在");
            } else {
              this.$refs["formWork"].validate((valid) => {
                if (valid) {
                  this.clrWorkHistoryList = this.clrWorkHistoryList;
                  this.clrWorkHistoryList.push(this.formWork);
                  this.dataTime = [];
                  this.formWork = {};
                  this.innerVisible = false;
                }
              });
            }
          });
        } else {
          this.$refs["formWork"].validate((valid) => {
            if (valid) {
              this.clrWorkHistoryList = this.clrWorkHistoryList;
              this.clrWorkHistoryList.push(this.formWork);
              this.dataTime = [];
              this.formWork = {};
              this.innerVisible = false;
            }
          });
        }
      }
    },
    // 删除工作经历
    handleDeleteClrWorkHistory() {
      this.clrWorkHistoryList = this.clrWorkHistoryList.filter(
        (item) => !this.workCname.some((it) => it.cName === item.cName)
      );
    },
    // 删除教育背景
    handleDeleteClrEducationHistory() {
      this.clrEducationList = this.educationSname.filter(
        (item) => !this.educationSname.some((it) => it.sName === item.sName)
      );
    },
    // 教育背景查看详情
    educationDetails(row) {
      console.log(row,'xiangq ')
      this.educationFrom = row;

      this.educationalVisible = true;
      this.educationDisabled = true;
    },
    // 工作经历查看详情
    workDetails(row) {
      this.dataTime = [];
      this.formWork = row;
      this.dataTime.push(row.startDate, row.endDate);
      this.innerVisible = true;
      this.workDisabled = true;
    },
    // 工作经历多选
    handleClrWorkHistorySelectionChange(selection) {
      this.workCname = selection;
      this.multiple = !selection.length;
    },
    // 教育背景多选
    handleClrEducationSelectionChange(selection) {
      this.educationSname = selection;
      this.multipleEducation = !selection.length;
    },
    // 教育背景参数添加
    submitEducation() {
      if (this.clrEducationList.length > 0) {
        this.clrEducationList.forEach((element) => {
          if (element.sName == this.educationFrom.sName) {
            this.$modal.msgWarning("添加的学校已存在");
          } else {
            this.$refs["educationFrom"].validate((valid) => {
              if (valid) {
                this.clrEducationList = this.clrEducationList;
                this.clrEducationList.push(this.educationFrom);
                this.educationalVisible = false;
                this.educationFrom = {};
              } else {
              }
            });
          }
        });
      } else {
        this.$refs["educationFrom"].validate((valid) => {
          if (valid) {
            this.clrEducationList = this.clrEducationList;
            console.log(this.educationFrom, "push");
            this.clrEducationList.push(this.educationFrom);
            console.log(this.clrEducationList, "添加");

            this.educationalVisible = false;
            this.educationFrom = {};
          } else {
          }
        });
      }
    },
    // 弹窗取消
    educationalCancel() {
      this.educationalVisible = false;
      this.resetForm("educationFrom");
    },
    // 清除表单
    CloseIn() {
      this.form = {};
      this.formTeacher = {};
      this.open = false;
    },
    // 选择未分配教师信息
    teacherSelectionChange(data) {
      if (data.length > 0) {
        this.formTeacher.tId = data[0].id;
      }
      console.log(data, "教师信息未分配");
    },
    // 获取搜索表单提交的数据
    onSearch(val) {
      // 查询条件和分页数据合并
      console.log(val.bnpId, "查询");
      if (val.bnpId) {
        val.bnpId = val.bnpId[val.bnpId.length - 1];
      }
      if(val.deptId) {
        val.deptId = val.deptId[val.deptId.length - 1];
      }
     
      this.queryParams = Object.assign(this.queryParams, val);
      console.log(this.queryParams, "查询");
      this.queryParams.pageNum = 1;
      this.getList();
    },
    // 重置
    onReset(data) {
      this.queryParams.pageNum = 1;
      this.queryParams.deptId = "";
      this.queryParams = Object.assign(this.queryParams, data);
      this.getList();
    },
    /** 查询角色列表 */
    getList() {
      this.loading = true;
      counsellorList(this.queryParams).then((response) => {
        console.log(response, "this.queryParams");
        this.roleList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;

      this.$refs.forms.clearValidate();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.roleId);
      this.names = selection.map(item => item.teacher.name);
      console.log(this.names,'s ')
      this.single = !selection.length;
      this.multiple = !selection.length;
    },
    // 多选框选中数据
    handleDelChange(selection) {
      this.classIds = selection.map(item => item.classId);
      this.multipleClass = !selection.length;

    },
    /** 新增按钮操作 */
    handleAdd() {
      this.dataList = [];
      this.clrWorkHistoryList = [];
      this.clrEducationList = [];
      this.form = {};
      this.formTeacher = {};
      this.open = true;
      this.title = "添加辅导员信息";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.dataList = [];
      this.formTeacher = {
        isClassThr: undefined,
        isClr: undefined,
      };
      const roleId = row.cId || this.ids;
      // this.formTeacher
      counsellorInfor(roleId).then((response) => {
        // this.form = response.data;
        this.open = true;
        this.dataList.push(response.data);
        this.formTeacher.isClassThr = response.data.isClassThr;
        this.formTeacher.isClr = response.data.isClr;
        this.formTeacher.tId = response.data.tId;
        this.formTeacher.cId = response.data.cId;
        this.clrWorkHistoryList = response.data.clrWorkHistoryList;
        this.clrEducationList = response.data.clrEducationList;
        console.log(this.dataList, "dataList");

        this.title = "修改辅导员信息";
      });
    },
    /** 提交按钮 */
    submitForm: function () {
      this.formTeacher.clrWorkHistoryList = this.clrWorkHistoryList;
      this.formTeacher.clrEducationList = this.clrEducationList;
      if (this.formTeacher.tId) {
        this.$refs["forms"].validate((valid) => {
          if (valid) {
            if (this.formTeacher.cId) {
              updataCounsellor(this.formTeacher).then((response) => {
                this.$modal.msgSuccess("修改成功");
                this.form = {};
                this.formTeacher = {};
                this.open = false;
                this.getList();
              });
            } else {
              counsellor(this.formTeacher).then((response) => {
                this.$modal.msgSuccess("新增成功");
                this.open = false;
                this.form = {};
                this.formTeacher = {};
                this.getList();
              });
            }
          }
        });
      } else {
        this.$modal.msgWarning("请选中修改的教师信息");
      }
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      console.log(row,'dfd')
      const roleIds = row.cId || this.ids;
      if(row.teacher) {
        console.log(row,'dfd1111')
        this.names = row.teacher.name 
      }
     
      this.$modal
        .confirm('是否确认删除辅导员"' +  this.names + '"的数据项？')
        .then(function () {
          return delCounsellor(roleIds);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "/clr/counsellor/export",
        {
          ...this.queryParams,
        },
        `辅导员信息${new Date().getFullYear()}-${
          new Date().getMonth() + 1
        }-${new Date().getDate()}.xlsx`
      );
    },
    /** 导出工作经历按钮操作 */
    experience() {
      this.download(
        "/clr/counsellor/clrWorkExport",
        {
          cId:this.cId
        },
        `辅导员工作经历${new Date().getFullYear()}-${
          new Date().getMonth() + 1
        }-${new Date().getDate()}.xlsx`
      );
    },
  },
};
</script>